<script setup lang="ts" name="PrintPreview">
import { getUrlParams } from '@/utils/ruoyi'
const ipcs = {
    initReport() {
        const { id } = getUrlParams(window.location.href)
        window.$.send('REPORT-PRINT-INIT', { id })
    },
    print(){
        window.$.send('PLUGIN-PRINT')
    }
}
const initListener = () => {
    window.$.listen("REPORT-PRINT-INIT-CALL", (e, data) => {
        const { reportTemplate, reportData } = data
        console.log('data', data)

        var reportViewer = window.rubylong.grhtml5.insertReportViewer("report_holder", '/report.grf', reportData);
        reportViewer.start();

        ipcs.print()
        console.log(reportData)
        console.log('reportViewer', reportViewer)
        // reportViewer.reportPrepared = false
        // reportViewer.dataPrepared = false
        // reportViewer.reportText = reportTemplate
        // reportViewer.dataText = reportData
        // reportViewer.loadReport(reportTemplate)
        // reportViewer.loadData(reportData) //数据请求IPS
        // reportViewer.start();
    })
}
onMounted(() => {
    initListener()
    ipcs.initReport()
})
</script>
<template>
    <div class="main-content print-preview">
        <div id="report_holder"></div>
    </div>
</template>
<style lang="scss"></style>
<style lang="scss" scoped></style>